package model.solver;

import java.io.BufferedWriter;
import java.io.IOException;

import controller.xml.XMLBaliseFormat;


/**
 * Class for managing of RSat parameter.
 * 
 * @author GRONOWSKI Stephane svan001@aol.com
 * 
 *         igsat 2010
 * 
 */
public class RSatParameter extends SolverParameter {

	private boolean	printSolution	= false;

	/**
	 * Return if it will get solution eventually find by rsat.
	 * 
	 * @return if it will get solution eventually find by rsat.
	 */
	public boolean isPrintSolution() {
		return printSolution;
	}

	/**
	 * Set to true if you it to get solution eventually find by rsat.
	 * 
	 * @param printSolution
	 *            if you want.
	 */
	public void setPrintSolution(boolean printSolution) {
		this.printSolution = printSolution;
	}

	/**
	 * Create a Rsat parameter.
	 */
	public RSatParameter() {
	}

	/**
	 * Create a Rsat parameter.
	 * 
	 * @param param
	 *            the {@link SolverParameter}
	 */
	public RSatParameter(SolverParameter param) {
		timeOut = param.getTimeOut();
	}

	/**
	 * Export the data in XML
	 * 
	 * @param file
	 *            {@link BufferedWriter} to write
	 * @throws IOException
	 */
	@Override
	public void exportXML(BufferedWriter file) throws IOException {

		// open
		// file.newLine();
		file.write("<" + XMLBaliseFormat.PARAMETER + " " + XMLBaliseFormat.TYPE_PARAMETER + "=" + "\""
				+ XMLBaliseFormat.TYPE_PARAMETER_SOLVEUR + "\"" + " >");

		// solver param
		super.exportXML(file);

		// solution
		// file.newLine();
		file.write("<" + XMLBaliseFormat.RSAT_SOLUTION + ">");
		if (isPrintSolution())
			file.write(XMLBaliseFormat.TRUE);
		else
			file.write(XMLBaliseFormat.FALSE);
		file.write("</" + XMLBaliseFormat.RSAT_SOLUTION + ">");

		// close
		// file.newLine();
		file.write("</" + XMLBaliseFormat.PARAMETER + ">");
	}

	@Override
	public boolean basicCheck() {
		if (timeOut != NO_DELAY && timeOut < MIN_DELAY)
			return false;

		return true;
	}
}
